<?php
$string = 'foo';
if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $string))
{
// one or more of the 'special characters' found in $string
}
/* EXAMPLE: <p>Bed & Breakfast</p> --> <p>Bed &amp; Breakfast</p>
& &amp;
" &quot; (unless ENT_NOQUOTES is set)
' &#039; or &apos; (ENT_QUOTES must be set)
< &lt;
> &gt; */
<?php
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new; // <a href='test'>Test</a>
?>